<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/js/jquery.js"></script>
    <link rel="stylesheet" href="/css/element-ui@2.13.2.index.css">
    <script src="/js/vue.min.js"></script>
    <script src="/js/vue-resource.min.js"></script>
    <script src="/js/index.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/axios.min.js"></script>
    <!-- 字体图标css的引入 -->
    <link rel="stylesheet" href="/css/font_830376_qzecyukz0s.css">
    <link rel="stylesheet" href="/css/color-dark.css">
    <link rel="stylesheet" href="/css/icon.css">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery.slim.min.js"></script>
    <script src="/js/popper.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <title></title>
</head>

<body>
    <div id="manage">
        <!-- 头部 -->
        <div class="wrapper">
            <!-- 头部 -->
            <div class="header">
                <!-- 折叠按钮 -->
                <div class="header-left">
                    人脸库管理
                </div>

                <!-- <div class="logo">后台管理系统</div> -->
                <div class="header-right">
                    <div class="header-user-con">
                        <!-- 全屏显示 -->
                        <div class="btn-fullscreen" @click="handleFullScreen">
                            <el-tooltip effect="dark" :content="fullscreen?`取消全屏`:`全屏`" placement="bottom">
                                <i class="el-icon-rank"></i>
                            </el-tooltip>
                        </div>
                        <div class="user-avator">
                            <img src="/image/img.jpg" />
                        </div>
                        <!-- 用户名下拉菜单 -->
                        <el-dropdown class="user-name" trigger="click" @command="handleCommand">
                            <span class="el-dropdown-link">
                                {{username}}
                                <i class="el-icon-caret-bottom"></i>
                            </span>
                            <el-dropdown-menu slot="dropdown">
                                <a href="https://github.com/lin-xin/vue-manage-system" target="_blank">
                                    <el-dropdown-item>项目仓库</el-dropdown-item>
                                </a>
                                <el-dropdown-item divided command="loginout">退出登录</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </div>
                </div>
            </div>

            <!-- 侧边部分 -->
            <div data-v-68d67528="" class="sidebar">
                <ul data-v-68d67528="" role="menubar" class="sidebar-el-menu el-menu side-ul"
                    style="background-color: rgb(50, 65, 87);">
                    <li data-v-68d67528="" role="menuitem" tabindex="-1" class="el-menu-item"
                        style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(50, 65, 87);"><i
                            data-v-68d67528="" class="el-icon-lx-home"></i><span data-v-68d67528="">首页</span></li>
                    <li data-v-68d67528="" role="menuitem" tabindex="-1" class="el-menu-item  is-active"
                        style="padding-left: 20px; color: rgb(32, 160, 255); background-color: rgb(50, 65, 87);"><i
                            data-v-68d67528="" class="el-icon-lx-calendar"></i><span data-v-68d67528="">人脸库管理</span>
                    </li>
                    <li data-v-68d67528="" role="menuitem" tabindex="-1" class="el-menu-item"
                        style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(50, 65, 87);"><i
                            data-v-68d67528="" class="el-icon-lx-global"></i><span data-v-68d67528="">特征查询</span></li>
                </ul>
            </div>

            <!-- 内容部分 -->
            <div class="content-box">
                <div class="content">
                    <div>
                        <div class="crumbs">
                            <el-breadcrumb separator="/">
                                <el-breadcrumb-item>
                                    <i class="el-icon-lx-cascades"></i> 人脸库管理
                                </el-breadcrumb-item>
                            </el-breadcrumb>
                        </div>
                        <div class="container">
                            <div class="handle-box">
                                <el-button type="primary" size="small" icon="el-icon-add" class="handle-del mr20"
                                    @click="handAdd" style="margin-right:20px">新增</el-button>
                            </div>
                            <el-table :data="tableData" border class="table" ref="multipleTable"
                                header-cell-class-name="table-header" @selection-change="handleSelectionChange">
                                <!-- <el-table-column width="55" align="center"></el-table-column> -->
                                <el-table-column prop="set_name" label="人脸库名称"></el-table-column>
                                <el-table-column prop="is_need_load" label="是否需要加载" :formatter="is_need_load_format"></el-table-column>
                                <el-table-column prop="model_version" label="特征版本"></el-table-column>
                                <el-table-column prop="set_type" label="人脸库类型" :formatter="set_type_format"></el-table-column>
                                <el-table-column prop="app_id" label="租户ID"></el-table-column>
                                <el-table-column prop="feature_size" label="特征维度"></el-table-column>
<!--                                <el-table-column prop="capacity" label="ID最大数量"></el-table-column>-->
<!--                                <el-table-column prop="strategy.slice_type" label="分片规则" :formatter="slice_type_format"></el-table-column>-->
<!--                                <el-table-column prop="strategy.slice_num" label="分片数"></el-table-column>-->
<!--                                <el-table-column prop="strategy.replication" label="副本数"></el-table-column>-->
<!--                                <el-table-column prop="strategy.search_type" label="检索类型" :formatter="search_type_format"></el-table-column>-->
<!--                                <el-table-column prop="strategy.cluster_center" label="聚类中心"></el-table-column>-->
<!--                                <el-table-column prop="threshold.distance_threshold" label="距离阈值"></el-table-column>-->
<!--                                <el-table-column prop="threshold.vote_threshold" label="投票阈值"></el-table-column>-->
<!--                                <el-table-column prop="threshold.autoregister_threshold" label="自动注册阈值"></el-table-column>-->
                                <el-table-column label="操作" width="250" align="center">
                                    <template slot-scope="scope">
                                        <el-button type="text"  size="small" icon="el-icon-lx-copy"
                                            @click="handleManage(scope.row)">查看人员</el-button>
                                        <el-button type="text"  size="small" icon="el-icon-info"
                                            @click="handleDetail(scope.row)">查看详情</el-button>
                                        <el-button type="text"  size="small" icon="el-icon-delete" class="red"
                                            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <div class="pagination">
                                <el-pagination background layout="total, prev, pager, next"
                                    :current-page="query.pageIndex" :page-size="query.pageSize" :total="pageTotal"
                                    @current-change="handlePageChange"></el-pagination>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        var manage = new Vue({
            el: '#manage',
            data: {
                fullscreen: false,
                query: {
                    address: '',
                    pageIndex: 1,
                    pageSize: 10
                },
                tableData: [
                ],
                multipleSelection: [],
                delList: [],
                editVisible: false,
                pageTotal: 0,
                form: {},
                idx: -1,
                id: -1
            },
            watch: {

            },
            computed: {
                username() {
                    let username = localStorage.getItem('ms_username');
                    return username ? username : this.name;
                }
            },
            mounted() {

            },
            created() {
                this.getData();
            },
            methods: {

                // 数据动态显示
                // 获取set_type(底库类型) 的数据
                set_type_format(row) {
                    switch (row.set_type) {
                        case 10:
                            return '静态底库';break;
                        case 20:
                            return '动态底库';break;
                        case 30:
                            return '抓拍库';break;
                        case 40:
                            return '聚类中心底库';break;
                        default:
                            return '静态底库';
                    }
                },

                // 获取 is_need_load 的数据
                is_need_load_format(row) {
                    if (row.is_need_load == true) {
                        return '是';
                    }else {
                        return '否';
                    }
                },

                // 获取 api接口数据
                getData() {

                    // 请求数据
                    // 调用自定义axios
                    axiosGetRequst('/api/library/list/' + this.query.pageIndex, null)
                        .then(result => {
                            if (result.status == 200) {
                                var num = parseInt(result.message);
                                if (num != 0 ) {
                                    this.tableData = result.data;
                                }
                                this.pageTotal = num;
                            } else {
                                this.$message.error(result.message);
                            }
                    });

                },
                // 删除操作
                handleDelete(index, row) {
                    // 二次确认删除
                    this.$confirm('确定要删除吗？', '提示', {
                        type: 'warning'
                    }).then(() => {
                            // 调用api接口删除人脸库
                            var url = '/api/library/delete/' + row.set_name;
                            if (!!row.model_version) {
                                url += '/' + row.model_version;
                            } else {
                                url += '/' + 'null';
                            }
                            axiosGetRequst(url)
                                .then(result => {
                                    if (result.status == 200) {
                                        this.$message.success('删除成功');
                                        this.tableData.splice(index, 1);
                                        this.pageTotal = (this.pageTotal - 1) || 10
                                    } else {
                                        this.$message.error(result.message);
                                    }
                                })
                        })
                        .catch(() => { });
                },
                // 多选操作
                handleSelectionChange(val) {
                    this.multipleSelection = val;
                },
                delAllSelection() {
                    const length = this.multipleSelection.length;
                    let str = '';
                    this.delList = this.delList.concat(this.multipleSelection);
                    for (let i = 0; i < length; i++) {
                        str += this.multipleSelection[i].name + ' ';
                    }
                    this.$message.error(`删除了${str}`);
                    this.multipleSelection = [];
                },
                // 查看详情
                handleDetail(row) {
                    var url = 'dataDetail?setName=' + row.set_name;
                    if(row.model_version.length === 0) {
                        url = url + '&modelVersion=null';
                    } else {
                        url = url + '&modelVersion=' + row.model_version;
                    }
                    window.location.href = url;
                },
                // 新增操作
                handAdd() {
                    window.location.href='dataAdd'
                },
                handleManage(row) {
                    var url = 'personManagement?setName=' + row.set_name;
                    if(row.model_version.length === 0) {
                        url = url + '&modelVersion=null';
                    } else {
                        url = url + '&modelVersion=' + row.model_version;
                    }
                    window.location.href = url;
                },
                // 分页导航
                handlePageChange(val) {
                    this.$set(this.query, 'pageIndex', val);
                    this.getData();
                },
                // 用户名下拉菜单选择事件
                handleCommand(command) {
                    if (command == 'loginout') {
                        localStorage.removeItem('ms_username');
                        window.localStorage["token"] = '';
                        window.location.href = 'login';
                    }
                },
                // 全屏事件
                handleFullScreen() {
                    let element = document.documentElement;
                    if (this.fullscreen) {
                        if (document.exitFullscreen) {
                            document.exitFullscreen();
                        } else if (document.webkitCancelFullScreen) {
                            document.webkitCancelFullScreen();
                        } else if (document.mozCancelFullScreen) {
                            document.mozCancelFullScreen();
                        } else if (document.msExitFullscreen) {
                            document.msExitFullscreen();
                        }
                    } else {
                        if (element.requestFullscreen) {
                            element.requestFullscreen();
                        } else if (element.webkitRequestFullScreen) {
                            element.webkitRequestFullScreen();
                        } else if (element.mozRequestFullScreen) {
                            element.mozRequestFullScreen();
                        } else if (element.msRequestFullscreen) {
                            // IE11
                            element.msRequestFullscreen();
                        }
                    }
                    this.fullscreen = !this.fullscreen;
                },
            }
        })

    </script>

</body>

</html>